﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BehaviorModel.Block.ServiceChannel;
using Model.Block;

namespace BehaviorModel.Statistic
{
    /// <summary>
    /// Behavior model for updating service channel statistic.
    /// </summary>
    public class ServiceChannelStatistic : IServiceChannelStatistic
    {
        #region Fields

        private IServiceChannel _serviceChannel;

        #endregion

        #region Properties

        public double WorkingTime
        {
            get { return _serviceChannel.Storage.WorkingTime; }
        }

        public double WaitingTime
        {
            get { return _serviceChannel.Storage.WaitingTime; }
        }

        public long CountOfServiced
        {
            get { return _serviceChannel.Storage.CountOfServiced; }
        }

        public long CountOfRejected
        {
            get { return _serviceChannel.Storage.CountOfRejected; }
        }

        public double RejectProbability
        {
            get
            {
                if (CountOfRejected + CountOfServiced != 0)
                    return ((double)CountOfRejected) / (CountOfRejected + CountOfServiced);
                return 0;
            }
        }

        public bool IsBusy { get { return _serviceChannel.IsBusy; } }

        public int QueueLength { get { return _serviceChannel.QueueLength; } }

        #endregion

        #region Constructor

        public ServiceChannelStatistic(IServiceChannel serviceChannel)
        {
            _serviceChannel = serviceChannel;
        }

        #endregion

        public void Update() { }
    }
}